//let serverIp = module.exports.serverIp = "http://file.sxycy.cn:81";
let serverIp = module.exports.serverIp = "http://file.sxycy.cn:82";


module.exports.getUserInfo = function ({encryptedData, iv, success, fail}) {
  //向服务端发送用户信息，并保存
  wx.request({
    url: serverIp + '/api/weixin/getuserbyencrypteddata/',
    header: { 
      'content-type': 'application/x-www-form-urlencoded',
      'Cookie': getSession()
       },
    data: {
      encryptedData: encryptedData,
      iv: iv
    },
    method: 'POST',
    success: success,
    fail: fail
  })
  
}

module.exports.saveSession = function (sessionId) {
  if (sessionId) {
    wx.setStorageSync("JSESSIONID", sessionId.slice(0, sessionId.indexOf(';')));//保存sessionid
  }
 
}

module.exports.getSession = function () {
  return wx.getStorageSync("JSESSIONID"); //保存sessionid
}